local yucheng = fk.CreateSkill{
  name = "#rfenghou_3d18j__yucheng_target",
}

yucheng:addEffect("active", {
  card_num = 1,
  card_filter = function(self, player, to_select, selected)
    return table.contains(self.expand_pile, to_select) and player:canUse(Fk:getCardById(to_select), { bypass_distances = true, bypass_times = true })
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    local first_filter = false
    if not selected[1] then
      first_filter = table.contains(self.selecteds, to_select) or table.contains(self.elses, to_select)
    else
      if table.contains(self.selecteds, selected[1]) then
        first_filter = table.contains(self.selecteds, to_select)
      else
        first_filter = table.contains(self.elses, to_select)
      end
    end
    if first_filter and selected_cards[1] then
      local card = Fk:getCardById(selected_cards[1])
      return player:canUseTo(card, to_select, { bypass_distances = true, bypass_times = true })
    end
  end,
  feasible = function(self, player, selected, selected_cards)
    if not selected[1] or not selected_cards[1] then
      return false
    else
      if table.contains(self.selecteds, selected[1]) then
        return table.isEqual(selected, self.selecteds)
      else
        return table.isEqual(selected, self.elses)
      end
    end
  end,
  target_tip = function(self, player, to_select, selected, _, _, selectable, extra_data)
    if table.contains(self.selecteds, to_select) then
      return "#rfenghou_3d18j__yucheng-target1"
    elseif table.contains(self.elses, to_select) then
      return "#rfenghou_3d18j__yucheng-target2"
    end
  end
})

Fk:loadTranslationTable{
  ["#rfenghou_3d18j__yucheng-target1"] = "重铸过牌",
  ["#rfenghou_3d18j__yucheng-target2"] = "未重铸过",
}

return yucheng
